package progress.exa28_1.part2;

/**
 * 定义任务类，这个任务类每隔一秒中打印指定的字符
 */
public class PrintChar implements Runnable {

    private final char charToPrint;

    private final int times;

    public PrintChar(char c,int t) {
        charToPrint = c;
        times = t;
    }

    @Override
    public void run() {
        for(int i=0;i<times;i++) {
            System.out.print(charToPrint);
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
                System.out.println("睡眠中断！！");
            }
        }
    }
}
